package com.hongshan.wallet.http

import com.google.gson.JsonElement
import com.hongshan.wallet.bean.AppVersionBean
import com.hongshan.wallet.bean.BankCardBean
import com.hongshan.wallet.bean.BannerListBean
import com.hongshan.wallet.bean.BindInfoBean
import com.hongshan.wallet.bean.CommListBean
import com.hongshan.wallet.bean.MoneyRecordBean
import com.hongshan.wallet.bean.OrderDescBean
import com.hongshan.wallet.bean.RealNameInfo
import com.hongshan.wallet.bean.TopUpBean
import com.hongshan.wallet.bean.UserBean
import com.hongshan.wallet.bean.UserDescBean
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query
import retrofit2.http.Streaming
import retrofit2.http.Url

/**
 * Copyright Qiandai Ltd.
 * Copyright (c) 2019
 * All rights reserved
 *
 * @project  : Wallet
 * @package  : com.example.wallet.util
 * @author   : Administrator
 * @data     : 2019/3/18
 * @email    : zhangxx@baihang-china.com
 */
interface HttpApi {

    @POST("api/v1/login.do")
    @Headers(HttpClient.JSON_HEAD)
    fun login(@Body json: JsonElement): Call<HttpResult<UserBean>>

    @POST("api/v1/register.do")
    @Headers(HttpClient.JSON_HEAD)
    fun register(@Body json: JsonElement): Call<HttpResult<UserBean>>

    @POST("api/v1/sms/{tel}")
    @Headers(HttpClient.JSON_HEAD)
    fun sendSms(@Path("tel") tel: String): Call<HttpResult<Map<String, String>>>

    @GET("api/v1/banner/{id}")
    @Headers(HttpClient.JSON_HEAD)
    fun getBanner(@Path("id") id: String): Call<HttpResult<BannerListBean>>

    @GET("api/v1/user/info")
    fun getUserDesc(): Call<HttpResult<UserDescBean>>

    @POST("api/v1/user/check_pay_passwd_code")
    @FormUrlEncoded
    fun checkPayPwdCode(@Field("code") code: String): Call<HttpResult<Map<String, String>>>

    @POST("api/v1/user/set_pay_passwd")
    @FormUrlEncoded
    fun setPayPwd(@Field("verify_code") verify_code: String, @Field("pay_passwd") pay_passwd: String, @Field("check_pay_passwd") check_pay_passwd: String): Call<HttpResult<Any>>

    @GET("api/v1/user/real_name")
    fun getRealName(): Call<HttpResult<RealNameInfo>>

    @GET("api/v1/order/list")
    fun getOrderList(
        @Query("pages") pages: Int? = null,
        @Query("number") number: Int? = null,
        @Query("status") status: Int? = null,
        @Query("start_time") start_time: Long? = null,
        @Query("end_time") end_time: Long? = null
    ): Call<HttpResult<CommListBean<OrderDescBean>>>

    @GET("api/v1/order/{orderId}")
    fun getOrderDesc(@Path("orderId") orderId: String): Call<HttpResult<OrderDescBean>>

    @POST("api/v1/user/investor_cash")
    @FormUrlEncoded
    fun requestWithdrawal(@Field("amount") amountv: String, @Field("account_card_id") account_card_id: String, @Field("verify_code") verify_code: String): Call<HttpResult<Any?>>

    @POST("api/v1/user/set_real_name")
    @FormUrlEncoded
    fun realNameCommit(@Field("real_name") real_name: String, @Field("id_type") id_type: String, @Field("credential_no") credential_no: String): Call<HttpResult<Any?>>

    @GET("api/v1/user/share")
    fun myInvite(): Call<HttpResult<JsonElement>>

    @GET("api/v1/user/recharge")
    fun topUpPageInfo(): Call<HttpResult<TopUpBean>>

    @POST("api/v1/user/do_recharge")
    @FormUrlEncoded
    fun topUpCommit(@Field("grade") grade: String, @Field("payment_method") payment_method: String): Call<HttpResult<Map<String,String>>>

    @POST("api/v1/bank_card/create")
    @FormUrlEncoded
    fun addBankCard(
        @Field("real_name") real_name: String,
        @Field("card_no") card_no: String,
        @Field("mobile") mobile: String,
        @Field("credential_no") credential_no: String? = null,
        @Field("id_type") id_type: String = "idcard"
    ): Call<HttpResult<BankCardBean>>

    //"verify_code"
    @POST("api/v1/user/check_pay_passwd")
    @FormUrlEncoded
    fun checkPayPwd(@Field("pay_passwd") pay_passwd: String): Call<HttpResult<Map<String, String>>>

    @GET("api/v1/account/list")
    fun getBindInfo(): Call<HttpResult<CommListBean<BindInfoBean>>>

    @POST("api/v1/account/bind")
    @FormUrlEncoded
    fun bindAccount(
        @Field("account") account: String,
        @Field("account_type") account_type: Int,
        @Field("qrcode") qrcode: String,
        @Field("status") status: Int
    ): Call<HttpResult<Any?>>

    @POST("api/v1/account/up_status")
    @FormUrlEncoded
    fun changeBindStatus(@Field("account_type") account_type: Int, @Field("status") status: Int): Call<HttpResult<Any?>>

    @POST("api/v1/account/un_bind")
    @FormUrlEncoded
    fun unBind(
        @Field("account_type") account_type: String,
        @Field("code") code: String
//        @Field("real_name") real_name: String,
//        @Field("id_type") id_type: String
//        @Field("credential_no") credential_no: String
    ): Call<HttpResult<Any?>>

    @GET("api/v1/bank_card/list")
    fun getBindBankCards():Call<HttpResult<CommListBean<BankCardBean>>>

    @POST("api/v1/notice_bind")
    @FormUrlEncoded
    fun websocket(@Field("client_id")client_id: String, @Field("investor_id")investor_id: String):Call<HttpResult<Any?>>

    @GET("api/v1/balance_detailed/list")
    fun getMoneyRecord(
        @Query("record_type") record_type: Int,
        @Query("type_details") type_details: Int?,
        @Query("pages") pages: Int,
        @Query("number") number: Int,
        @Query("start_time") start_time: Long?,
        @Query("end_time") end_time: Long?
    ):Call<HttpResult<CommListBean<MoneyRecordBean>>>

    @POST("api/v1/user/change_balance")
    @FormUrlEncoded
    fun intoBalance(@Field("commission_balance")commission_balance:String):Call<HttpResult<Any>>

    @POST("api/v1/account/is_order_taking")
    @FormUrlEncoded
    fun updateOrderReceiveState(@Field("status") status: Int):Call<HttpResult<Any>>


    @POST("api/v1/user/do_recharge")
    @FormUrlEncoded
    fun commitTopUp(@Field("payment_method") payment_method: String, @Field("pic_url") pic_url: String): Call<HttpResult<Any>>

    /**
     * "url": "/uploads/file/20190409/51525486040a568d3ff2c477845e01bd.jpeg"
     */
    @POST
    fun uploadFile(@Url url: String, @Body body: RequestBody): Call<HttpResult<Map<String, String>>>

    @GET
    @Streaming
    fun downloadFile(@Url url: String): Call<ResponseBody>

    /**
     * 签名KEY：2bHg2U@nAG7q$4Fh
     */
    @POST("api/v1/messages")
    @FormUrlEncoded
    fun receiveCofirm(
        @Field("type") type: Int,
        @Field("userids") userids: String,
        @Field("money") money: String,
        @Field("mark") mark: String?,
        @Field("dt") dt: String,
        @Field("sign") sign: String
    ): Call<HttpResult<Any>>


    @POST("api/v1/appIsUpdate")
    @FormUrlEncoded
    fun update(@Field("current_version")version:String):Call<HttpResult<AppVersionBean>>
}